{extend name="base/base" /}
{block name="style"}
<style type="text/css">

</style>
{/block}
{block name="content"}
  <div class="layui-form-item layui-form-pane">
      
      <div class="layui-inline">
        <label class="layui-form-label">地址</label>
          <div class="layui-input-inline">
            <input type="text" name="address" autocomplete="off" class="layui-input" id='address'>
          </div>
      </div>
      
      <div class="layui-inline">
        <div class="demoTable">
          <button class="layui-btn" data-type="reload">搜索</button>
          <!-- <button class="layui-btn" onclick="excel()">导出表</button> -->
        </div>
      </div>
  <table id="table" lay-filter="table"></table> 
</div>
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  table.render({
    elem: '#table'
    ,height: 'full-200'
    ,url: '/admin/record/dataList/' //数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'reload'
    ,cols: [[ //表头
      {field:'uid', title: '用户ID', width: 100 }
      ,{field:'address', title: '地址', width: 350 }
      ,{field:'name', title: '币种', width: 350 }
      ,{field:'balance', title: '变动金额', width: 200,templet: function(d){
          if (d.balance>0) {
          return '<span style="color:red">'+d.balance+'</span>'
          } else {
            return '<span style="color:green">'+d.balance+'</span>'
          }
      }}
      ,{field:'remark', title: '备注', width: 300}
      ,{field:'detail_remark', title: '详细备注', width: 300}
      ,{field:'date', title: '时间', width: 300}
    ]]
  }); 
        //日期
  laydate.render({
    elem: '#start_time'
  });
  laydate.render({
    elem: '#end_time'
  });
  // 搜索
  var $ = layui.$, active = {
        reload: function(){
            table.reload('reload', {
                where: {
                    address: $('#address').val(),
                }
            });
        }
    };
    $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>
{/block}
